package cn.stylefeng.guns.modular.system.controller;

import cn.stylefeng.guns.modular.system.entity.Return;
import cn.stylefeng.guns.modular.system.model.params.ReturnParam;
import cn.stylefeng.guns.modular.system.service.ReturnService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 控制器
 *
 * @author 小飞
 * @Date 2019-06-24 11:09:14
 */
@Controller
@RequestMapping("/return")
public class ReturnController extends BaseController {

    private String PREFIX = "/return";

    @Autowired
    private ReturnService returnService;

    /**
     * 跳转到主页面
     *
     * @author 小飞
     * @Date 2019-06-24
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/return.html";
    }

    /**
     * 新增页面
     *
     * @author 小飞
     * @Date 2019-06-24
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/return_add.html";
    }

    /**
     * 编辑页面
     *
     * @author 小飞
     * @Date 2019-06-24
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/return_edit.html";
    }

    /**
     * 新增接口
     *
     * @author 小飞
     * @Date 2019-06-24
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(ReturnParam returnParam) {
        this.returnService.add(returnParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author 小飞
     * @Date 2019-06-24
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(ReturnParam returnParam) {
        this.returnService.update(returnParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author 小飞
     * @Date 2019-06-24
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(ReturnParam returnParam) {
        this.returnService.delete(returnParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author 小飞
     * @Date 2019-06-24
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(ReturnParam returnParam) {
        Return detail = this.returnService.getById(returnParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author 小飞
     * @Date 2019-06-24
     */
   /* @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(ReturnParam returnParam) {

        LayuiPageInfo returnServicePageBySpec = this.returnService.findPageBySpec(returnParam);
        List<ReturnVO> returnVOS = returnServicePageBySpec.getData();

        List<ReturnVO> returnVOList = new ArrayList<>();
        ReturnVO returnVOUse = null;
        for (ReturnVO returnVO : returnVOS){

            returnVOUse = new ReturnVO();
            BeanUtils.copyProperties(returnVO,returnVOUse);
            returnVOUse.setStatusDesc(returnVOUse.getStatusDesc(returnVO.getStatus()));
            returnVOUse.setPath(SystemConstant.TENCENT_URL+"20190624160803_6705.jfif");
            returnVOList.add(returnVOUse);
        }
         returnServicePageBySpec.setData(returnVOList);
        return returnServicePageBySpec;

    }*/

}


